/**
 * Copyright (C) Le Minh Sang Tran (meo), 2011
 */
package ms.unicorn.impl;

import ms.unicorn.*;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;

import org.eclipse.emf.ecore.impl.EFactoryImpl;

import org.eclipse.emf.ecore.plugin.EcorePlugin;
import org.eclipse.emf.ecore.util.EcoreUtil;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model <b>Factory</b>.
 * <!-- end-user-doc -->
 * @generated
 */
public class UnicornFactoryImpl extends EFactoryImpl implements UnicornFactory {
	/**
	 * Creates the default factory implementation.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public static UnicornFactory init() {
		try {
			UnicornFactory theUnicornFactory = (UnicornFactory)EPackage.Registry.INSTANCE.getEFactory("http://ms.unicorn"); 
			if (theUnicornFactory != null) {
				return theUnicornFactory;
			}
		}
		catch (Exception exception) {
			EcorePlugin.INSTANCE.log(exception);
		}
		return new UnicornFactoryImpl();
	}

	/**
	 * Creates an instance of the factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public UnicornFactoryImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public EObject create(EClass eClass) {
		switch (eClass.getClassifierID()) {
			case UnicornPackage.DIAGRAM: return createDiagram();
			case UnicornPackage.ENTITY: return createEntity();
			case UnicornPackage.RELATION: return createRelation();
			default:
				throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT added the UUID, and set the elementType to diagram
	 */
	public Diagram createDiagram() {
		DiagramImpl diagram = new DiagramImpl();
		diagram.setId(EcoreUtil.generateUUID());
		diagram.setElementType("DIAGRAM");
		return diagram;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT added the UUID
	 */
	public Entity createEntity() {
		EntityImpl entity = new EntityImpl();
		entity.setId(EcoreUtil.generateUUID());
		return entity;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT added the UUID, and change the element type
	 */
	public Relation createRelation() {
		RelationImpl relation = new RelationImpl();
		relation.setId(EcoreUtil.generateUUID());
		relation.setElementType("RELATION");
		return relation;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public UnicornPackage getUnicornPackage() {
		return (UnicornPackage)getEPackage();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @deprecated
	 * @generated
	 */
	@Deprecated
	public static UnicornPackage getPackage() {
		return UnicornPackage.eINSTANCE;
	}

} //UnicornFactoryImpl
